package com.ruoyi.interview.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.interview.domain.TbInterview;
import com.ruoyi.interview.service.ITbInterviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 面试Controller
 * 
 * @author ruoyi
 * @date 2023-01-29
 */
@RestController
@RequestMapping("/interview")
public class TbInterviewController extends BaseController
{
    @Autowired
    private ITbInterviewService tbInterviewService;

    /**
     * 查询面试列表
     */
    @RequiresPermissions("interview:interview:list")
    @GetMapping("/list")
    public TableDataInfo list(TbInterview tbInterview)
    {
        startPage();
        List<TbInterview> list = tbInterviewService.selectTbInterviewList(tbInterview);
        return getDataTable(list);
    }

    /**
     * 导出面试列表
     */
    @RequiresPermissions("interview:interview:export")
    @Log(title = "面试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbInterview tbInterview)
    {
        List<TbInterview> list = tbInterviewService.selectTbInterviewList(tbInterview);
        ExcelUtil<TbInterview> util = new ExcelUtil<TbInterview>(TbInterview.class);
        util.exportExcel(response, list, "面试数据");
    }

    /**
     * 获取面试详细信息
     */
    @RequiresPermissions("interview:interview:query")
    @GetMapping(value = "/{interviewId}")
    public AjaxResult getInfo(@PathVariable("interviewId") Long interviewId)
    {
        return success(tbInterviewService.selectTbInterviewByInterviewId(interviewId));
    }

    /**
     * 新增面试
     */
    @RequiresPermissions("interview:interview:add")
    @Log(title = "面试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbInterview tbInterview)
    {
        return toAjax(tbInterviewService.insertTbInterview(tbInterview));
    }

    /**
     * 修改面试
     */
    @RequiresPermissions("interview:interview:edit")
    @Log(title = "面试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbInterview tbInterview)
    {
        return toAjax(tbInterviewService.updateTbInterview(tbInterview));
    }

    /**
     * 删除面试
     */
    @RequiresPermissions("interview:interview:remove")
    @Log(title = "面试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{interviewIds}")
    public AjaxResult remove(@PathVariable Long[] interviewIds)
    {
        return toAjax(tbInterviewService.deleteTbInterviewByInterviewIds(interviewIds));
    }
}
